﻿@{
    Layout = null;
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" />
<html>
<head>
    <title>平时成绩管理系统</title>
    <link href='@Url.Content("~/Content/css/LoginStyle.css")' rel="stylesheet" type="text/css" />
    <link href='@Url.Content("~/Content/css/SimpleDialog.css")' rel="stylesheet" type="text/css" />
    <script src='@Url.Content("~/Scripts/jquery-1.5.1.min.js")' type="text/javascript"></script>
    <script src='@Url.Content("~/Scripts/jquery.simplemodal.1.4.1.min.js")' type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $.ajaxSetup({ cache: false });
            SetPosition(); //调整页面
            window.onresize = function () { SetPosition(); };  //屏幕大小改变时调整页面


            $("#ForgetPassword").click(function () {
                var Num = $("#txtAccount").val();
                if (Num.length > 0) {
                    $.get("../Account/ResetPassword", { Account: Num }, function (data) {
                        if (data == "0") {
                            alert("提交重置未成功！");
                        } else {
                            alert("提交重置成功！");
                        }
                    })

                } else {
                    alert("用户名不能为空！");
                }
            })

        })

        function SetPosition() {
            var screenWidth = getTotalWidth(); //获取浏览器可显示内容的宽度
            var screenHeight = getTotalHeight(); //获取浏览器可显示内容的高度
            var marginLeft = (screenWidth - 600) / 2;
            var marginTop = (screenHeight - 249) / 2 - 75;
            $("#loginFram").css("margin-left", marginLeft + "px");
            $("#loginFram").css("margin-top", marginTop + "px");

        }

        function getTotalHeight() {//获取浏览器可用于显示页面的高度
            if ($.browser.msie) {//如果浏览器是IE
                //如果是兼容性模式则用document.documentElement.clientHeight试获取
                return document.compatMode == "CSS1Compat" ? document.documentElement.clientHeight :
                         document.body.clientHeight;
            } else {//其它浏览器
                return self.innerHeight;
            }
        }

        function getTotalWidth() {//获取浏览器可用于显示页面的宽度

            if ($.browser.msie) {//如果浏览器是IE
                //如果是兼容性模式则用document.documentElement.clientWidth
                return document.compatMode == "CSS1Compat" ? document.documentElement.clientWidth :
                         document.body.clientWidth;
            } else {//其它浏览器
                return self.innerWidth;
            }
        }

        $(function () {
            //首次加载
            $("#checkCode").attr("src", "/Common/GetCheckCode?time=" + (new Date()).getTime());
            $.get("/Common/GetCurrentCheckCode", function (data) {
                $("#checkCode").val(data);
            });
            //单击验证码事件
            $("#checkCode").bind("click", function () {
                this.src = "/Common/GetCheckCode?time=" + (new Date()).getTime();
                $.get("/Common/GetCurrentCheckCode", function (data) {
                    $("#checkCode").val(data);
                });
            });
        });

        function CheckPage() {
            if ($("#txtAccount").val() == "") {
                alert("请填写用户名！");
                return false;
            }
            if ($("#txtPassword").val() == "") {
                alert("请填写密码！");
                return false;
            }
            if ($("#txtCheckCode").val() == "") {
                alert("请填写验证码！");
                return false;
            }
            Login();
        }

        function reset() {
            $("#txtAccount").val("");
            $("#txtPassword").val("");
            $("#txtCheckCode").val("");
            $("#checkCode").click();
        }

        function Login() {
            $.ajax({
                type: "GET",
                url: "/Account/AJAXLogin",
                data: { account: function () { return $("#txtAccount").val() }, password: function () { return $("#txtPassword").val() }, checkCode: function () { return $("#txtCheckCode").val() } },
                beforeSend: function () { $.modal("<img src='../../Content/images/loading.gif' alt=''/>"); },
                success: function (msg) {
                    if (msg == "success") {
                        window.location = "/Home/Index";
                    }
                    else {
                        alert(msg);
                    }
                },
                complete: function () {
                    $("#txtPassword").val("");
                    $("#txtCheckCode").val("");
                    $("#divCheckCode").empty();
                    $("#checkCode").attr("src", "/Common/GetCheckCode?time=" + (new Date()).getTime());
                    $.get("/Common/GetCurrentCheckCode", function (data) {
                        $("#checkCode").val(data);
                    });
                    $("#divCheckCode").append('<img id="checkCode" class="checkCode" src="/Common/GetCheckCode" alt="" />');
                    $.modal.close();
                }
            });

        }

        
    </script>
</head>
<body>
    <div id="All">
        <center>
            <div id="logincontent">
                <div id="top">
                    <div id="logo">
                    </div>
                    <div id="TestTitle">
                        Usual Performance Management System</div>
                </div>
                <div style="width: 464px;">
                    <div style="width: 250px; height: 100px; padding-top: 17px; float: left; margin-left: 50px;" id="Y">
                        <div style="height: 27px; float: left;">
                            &nbsp;Account:<input type="text" id="txtAccount" name="Account" />
                        </div>
                        <br />
                        <div style="height: 27px; float: left;">
                            Password:<input type="password" id="txtPassword" name="Password" />
                        </div>
                        <div style="height: 27px; float: left; margin-left: -6px;" class="divTxtCheckCode">
                            CheckCode:<input type="text" id="txtCheckCode" style="width: 87px;" />
                        </div>
                        <div class="divCheckCode" style="float: left; margin-left: 7px;">
                            <img id="checkCode" class="checkCode" src="Common/GetCheckCode" alt="" />
                        </div>
                    </div>
                    <div style="width: 100px; height: 100px; float: left; padding-top: 20px;">
                        <div style="height: 29px;">
                            <input type="button" id="submit" onclick="CheckPage() " />
                        </div>
                        <div style="height: 29px;">
                            <input type="button" id="reset" onclick="reset()"/>
                        </div>
                        <div style=" font-size:small; color:Red;"><a id="ForgetPassword">忘记密码？</a> </div>
                    </div>
                    <div id="text">
                        Conpyright 2013 www.zdclub.net</div>
                </div>
            </div>
        </center>
    </div>
</body>
</html>
